package com.arraylistdemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class ArrayListDemp {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        add(list);
    }


    public static void add(List<String> list) {
        Collections.addAll(list,"xiaoming","xiaohong","zhangsan") ;
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        Iterator<String> iterator = list.iterator();  // 迭代器 循环取出值
        while (iterator.hasNext()) {
            String next = iterator.next();
            System.out.println(next);
        }
        list.set(0,"zhangsan");
        System.out.println(list);
    }
}
